package com.gao.e_topic;

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Channel;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author gao
 * @time 2022/07/05 11:22:10
 */
//@Component
public class Consumer {
    @RabbitListener(
            bindings = {
                    @QueueBinding(
                            value = @Queue,
                            exchange = @Exchange(value = "topic_logs", type = ExchangeTypes.TOPIC),
                            key = "*.orange.*"
                    )
            }
    )
    public void recevie(String msg, Channel channel) {
        System.out.println("A: " + msg);
    }

    @RabbitListener(
            bindings = {
                    @QueueBinding(
                            value = @Queue,
                            exchange = @Exchange(value = "topic_logs", type = ExchangeTypes.TOPIC),
                            key = {"*.*.rabbit", "lazy.#"}
                    )
            }
    )
    public void recevie2(String msg, Channel channel) {
        System.out.println("B: " + msg);
    }
}
